//
//  YDAddButton.swift
//  weibo
//
//  Created by 孙亚东 on 16/6/29.
//  Copyright © 2016年 Sunyadong. All rights reserved.
//

import UIKit

class YDAddButton: UIButton {


    override init(frame: CGRect) {
        
        super.init(frame: frame)
        
        
        setupUI()
        
    }

    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
        
        
    }
    
    
    func setupUI() {
    
        imageView?.contentMode = .Center
        
        
        titleLabel?.textAlignment = .Center
        
        setTitleColor(UIColor.blackColor(), forState: .Normal)
    
    
    }
    
    // 重写layoutSubViews方法，改变ImageView和lab的布局
    
    
    override func layoutSubviews() {
        
        super.layoutSubviews()
        
        
        //设置imaageView的布局
        var imageFrame = imageView?.frame
        
        imageFrame?.size = CGSizeMake(self.bounds.width, self.bounds.width)
        imageFrame?.origin.x = 0
        imageFrame?.origin.y = 0
        
        imageView?.frame = imageFrame!
    
        
        var fram = titleLabel?.frame

        fram?.origin.y = self.bounds.size.width
        fram?.origin.x = 0
        fram?.size.width = self.bounds.size.width
        titleLabel?.frame = fram!
        
        
        
        
        
    }

}
